﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SportsStore.Domain.Abstract;
using SportsStore.Domain.Concrete;
using System.ComponentModel;

namespace SportsStore.WebUI.Controllers
{
    public class ProductsController : Controller
    {
        //
        // GET: /Products/

        private IProductsRepository productsRepository;
        //public ProductsController()
        //{
        //    // This is just temporary until we have more infrastructure in place
        //    productsRepository = new FakeProductsRepository();
        //}

        //public ProductsController()
        //{
        //    // Temporary hard-coded connection string until we set up dependency injection
        //    string connString = @"Server=WINDOWS-MKU2KNE;Database=SportsStore;Trusted_Connection=yes;";
        //    productsRepository = new SqlProductsRepository(connString);
        //}
        public int PageSize = 2;
        public ProductsController(IProductsRepository productsRepository)
        {
            this.productsRepository = productsRepository;
        }

        //public ViewResult List()
        //{
        //    return View(productsRepository.Products.ToList());
        //}



        //public int PageSize { get; set; }

        public ViewResult List(int page = 1)
        {
            return View(productsRepository.Products
.Skip((page - 1) * PageSize)
.Take(PageSize)
.ToList()
);
        }
    }
}
